<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Supplier extends BaseModel
{
    use HasFactory;
    //供应商

    protected $table = 'supplier';
    // 允许批量操作的字段
    protected $fillable = [
        'code',
        'name',
        'type',
        'link_man',
        'tel',
        'address',
        'bank_name',
        'bank_account',
        'status',
        'is_del',
        'created_at',
        'updated_at'
    ];

    public function scopeSearch($query,$params)
    {
        if(!empty($params['code'])){
            $query->where('code',$params['code']);
        }
        if(!empty($params['name'])){
            $query->where('name',$params['name']);
        }
        $query->where('is_del',$params['is_del']??2);
        return $query;
    }

}
